<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<link href="/js/kindeditor-4.1.10/themes/default/default.css" type="text/css" rel="floorsheet">
<script type="text/javascript" charset="utf-8" src="/js/kindeditor-4.1.10/kindeditor-all-min.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/kindeditor-4.1.10/lang/zh_CN.js"></script>
<div floor="padding:10px 10px 10px 10px">
	<form id="floorAddForm" class="itemForm" method="post">
	    <table cellpadding="5">


	        <tr>
	            <td>地板样式:</td>
	            <td><input class="easyui-textbox" type="text" name="floorKind" data-options="validType:'length[1,30]'"/>
	            	<!-- <input type="hidden" name="price"/> -->
	            </td>
	        </tr>
	        <tr>
	            <td>地板颜色:</td>
	            <td>
	                <input class="easyui-textbox" type="text" name="floorColor" data-options="validType:'length[1,30]'" />
	            </td>
	        </tr>
	        <tr>
	            <td>价格:</td>
	            <td>
	                <input class="easyui-textbox" type="text" name="floorPrice" data-options="validType:'length[1,30]'" />
	            </td>
	        </tr>
	        <tr>
	            <td>地板图片:</td>
	            <td><input class="easyui-linkbutton" type="file" name="floorPicture" /></td>
	        </tr>


	    </table>
	    <input type="hidden" name="itemParams"/>
	</form>
	<div floor="padding:5px">
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
	    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
	</div>
</div>
<script type="text/javascript">

	//提交表单
	function submitForm(){
		//有效性验证
		if(!$('#floorAddForm').form('validate')){
			$.messager.alert('提示','表单还未填写完成!');
			return ;
		}

		//同步文本框中的商品描述
	
		//取商品的规格
		/*
		var paramJson = [];
		$("#itemAddForm .params li").each(function(i,e){
			var trs = $(e).find("tr");
			var group = trs.eq(0).text();
			var ps = [];
			for(var i = 1;i<trs.length;i++){
				var tr = trs.eq(i);
				ps.push({
					"k" : $.trim(tr.find("td").eq(0).find("span").text()),
					"v" : $.trim(tr.find("input").val())
				});
			}
			paramJson.push({
				"group" : group,
				"params": ps
			});
		});
		//把json对象转换成字符串
		paramJson = JSON.stringify(paramJson);
		$("#itemAddForm [name=itemParams]").val(paramJson);
		*/
		//ajax的post方式提交表单
		//$("#itemAddForm").serialize()将表单序列号为key-value形式的字符串
		 /* console.log($("#itemAddForm").serializeArray());  */
/* 		 var data = {
				 floorKind: $("input[name='floorKind']").val(),
				 floorPicture:   $("input[name='floorPicture']").val(),
				 floorColor: $("input[name='floorColor']").val(),
				 floorPrice:$("input[name='floorPrice']").val(),
				
		 };
		 console.log(data);  */
	     var formdata = new FormData($('#floorAddForm')[0]);
	     console.log(formdata);
	     $.ajax({  
	          url: 'floor/save' ,  
	          type: 'POST',  
	          data: formdata, 
	          async: false,  
	          cache: false,  
	          contentType: false,  
	          processData: false, 
	          success: function(data){ 
					$.messager.alert('提示','新增地板成功!');
					$('#floorAddForm').form('reset');}, 
			  dataType: "text",
	     }); 
		 


	} 
	
	function clearForm(){
		$('#floorAddForm').form('reset');
	}
</script>
